package com.wzxy.pf.loginlog.service.impl;

import com.wzxy.pf.loginlog.entity.User;
import com.wzxy.pf.loginlog.mapper.UserMapper;
import com.wzxy.pf.loginlog.service.UserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zhl
 * @since 2023-04-01
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {
@Resource
UserMapper userMapper;
@Override
    public User find(User user) {
    userMapper.find(user);
    System.out.println(userMapper.find(user));
        return userMapper.find(user);
    }

    @Override
    public int saveUser(User user) {
        SimpleDateFormat formatter= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date date = new Date(System.currentTimeMillis());
        String createtime=formatter.format(date);
   user.setIsDelete(0);
user.setCreateTime(createtime);
        return  userMapper.insert(user);
    }

    @Override
    public User findByid(Integer id) {
        return userMapper.findById(id);
    }
}
